package model.primitive;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

import javax.vecmath.Point3d;
import javax.vecmath.Vector3d;


import model.PrimitiveColor;
import model.Scene;
import model.ray.Ray;

@SuppressWarnings("unused")
public class Intersection {
	public List<IntersectionData> hits;
		
	public Intersection (Ray ray, Scene scene) {
		this.hits = new ArrayList<IntersectionData>();
		Point3d curr = null;
		Double dist, currdist;
		Primitive prim;
		
		dist = null;
		curr = null;
		prim = null;
		
		for( Primitive primitive :  scene.getPrimitives() ) {
			List<Point3d> intersections = primitive.getIntersections(ray);
			if( intersections != null && intersections.size() > 0 ) {
				for( Point3d intersection : intersections )	{
					Double distance = ray.getDistance(intersection);
					IntersectionData intersectionData = new IntersectionData(ray, primitive, intersection, distance);
				 	this.hits.add(intersectionData);
				}
			}
		}
		//La idea es retornar ordenados segun la distancia.
		Collections.sort(this.hits);
	}
	
	public PrimitiveColor getColor() {
		
		return null;
	}
	
}
